﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Web.UI.WebControls;
using System.Data;
using System.Linq;

public partial class SiteMaster : System.Web.UI.MasterPage
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<Category> lstCat = Category.GetAllCategories();
            if (lstCat.Count > 5)
            {
                lbtnMoreCategories.Visible = true;
                lstCat = lstCat.Take(5).ToList();
            }
            repCat.DataSource = lstCat;
            repCat.DataBind();

            List<Author> lstAuth = Author.GetAllAuthors();
            if (lstAuth.Count > 5)
            {
                lbtnMoreAuthors.Visible = true;
                lstAuth = lstAuth.Take(5).ToList();
            }
            repAuthors.DataSource = lstAuth;
            repAuthors.DataBind();

            List<Publisher> lstPub = Publisher.GetAllPublishers();
            if (lstPub.Count > 5)
            {
                lbtnMorePublishers.Visible = true;
                lstPub = lstPub.Take(5).ToList();
            }
            repPublishers.DataSource = lstPub;
            repPublishers.DataBind();
        }
    }
    
    protected void lbtnMoreCategories_Click(object sender, EventArgs e)
    {
        repCat.DataSource = Category.GetAllCategories();
        repCat.DataBind();
    }
    protected void lbtnMoreAuthors_Click(object sender, EventArgs e)
    {
        repAuthors.DataSource = Author.GetAllAuthors();
        repAuthors.DataBind();
    }
    protected void lbtnMorePublishers_Click(object sender, EventArgs e)
    {
        repPublishers.DataSource = Publisher.GetAllPublishers();
        repPublishers.DataBind();
    }
}
